using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Configuration;
using System.Web.UI;
using System.Web.UI.WebControls;
 
public partial class JobSeekers_viewletter : System.Web.UI.Page
{
    string connectionString = "";
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            connectionString =
                 WebConfigurationManager.ConnectionStrings[
                   "RecruitVietnam"].ConnectionString;

            Common common = new Common();
            this.ClientScript.RegisterClientScriptBlock(
            this.GetType(), "openWindowLetter", 
            common.CreateScriptForPrint("Letter"));
            this.btnPrint.Attributes.Add("onclick",
            "openWindowLetter" +
            "('Letter',400,700);return false;");

            if (Session.Contents["jsuserid"] == null)
            {
                Response.Redirect("login.aspx");
            }
            else
            {
                string letterID = "";
                letterID = 
                Request.QueryString.Get("letterid");
                if (!IsPostBack)
                {
                    ShowLetter(letterID);
                }
            }
         }
         catch(Exception ex)
         {
            literalError.Text = ex.Message;
         }
    }
    void ShowLetter(string letterID)
    {
        SqlServerProvider cls = new SqlServerProvider(connectionString);
        cls.CommandText = "select  * from tblJSCoverLetters where UserID=@UserID and LetterID=@LetterID;";
        cls.ParameterCollection = new string[2] { "@UserID", "@LetterID" };
        cls.ValueCollection = new string[2]{Convert.ToString(
        Session.Contents["jsuserid"]), letterID};
        
        DataRow dataRow= cls.GetDataRow();
        literalBody.Text = dataRow["Body"].ToString();
        
    }
     
}
